#!/bin/sh
# Created 2010-03-17 by Jimmy Wu
# Arguments:
#  $1:	path of gss txt file
# Creates a file 

# temporary files:
# gss.gpi gnuplot information
# gss.temp

GPI=gss.gpi
#gpi_template=gnuplot.gpi
gsstemp=gss.temp

usage() {
	echo Usage: "$0" gssfile
	echo Outputs a svg file using gnuplot
}

if [ -z "$1" ] ; then
	usage()
	exit 1;
fi

gssfile="$1"
output=${gssfile}.svg

# path to gnuplot
Gnuplot=`which gnuplot`

: > $GPI

echo "infile='$gsstemp'" >> $GPI
echo "outfile='$output'" >> $GPI
cat >> $GPI << EOF
unset xtics
unset ytics
unset border
unset key
set terminal svg
set output outfile
plot infile using 1:2 with linespoints pointtype 7 pointsize .75 linecolor rgb "black"
EOF


sed -e 's/\([[:digit:].]* [[:digit:].]*\) \([[:digit:].]* [[:digit:].]*\)/\1\n\2\n/' $gssfile > $gsstemp

$Gnuplot $GPI

# clean up
#/bin/rm $GPI
#/bin/rm $gsstemp

exit
